import requestApi from '../../utils/api.js'
 class HousePage{
	 init(data,flg=false){
		 const page = flg? data.page : (data.page=1)
		 const params = {
			 type:'home',
			 page,
			 size:10
		 }
		 requestApi('refuge',params).then(res=>{
			 console.log(res);
			 if(res.result.code===200){
				 res.result.data.forEach(item=>{
					 let obj = {
						 imgs: item.images,
						 title: item.address.name,
						 price: item.price,
						 dos: item.roomTypename + ' '+ item.roomname+' '+item.hallsname+' '+item.sexname
					 }
					 data.list.push(obj)
				 })
				 data.nomore = res.result.data.length<10? true : false
				 data.noList = false
			 }else{
				 data.noList  = true
				 data.nomore = true
				 data.list = data.list.length>0?data.list:[]
			 }
		 })
	 }
	 // 选择城市的列表选择器
	cityChange(data,e){
		const index = e.detail.value
		data.index=index
		
	}
	//功能区的点击事件
	funBtn(k,popup){
		const action = {
			0: ()=>this.funBtnCom(),
			1: ()=>this.funBtnCom('/pages/refuge/refuge'),
			2: ()=>{
				
				uni.showModal({
					title:'提示',
					content:'请手动在微信上进行添加，wx:110',
					showCancel:false,
					confirmText:'好的',
					
				})
			},
			3: ()=>this.funBtnCom(),
			4: ()=>{//显示弹框打赏
				popup.value.open()
				// this.$refs.popup.open('top')
						
			},
			5: ()=>this.funBtnCom('/pages/publish/publish'),
		}
		console.log(action[k]());
		return action[k]()
		
	}
	
	//功能区相同的逻辑进行跳转
	funBtnCom(url){
		return uni.navigateTo({
			url
		})
		// return 1
	}
	//点击跳转到详情页面
	goDetail(val){
		uni.navigateTo({
			url:'/pages/detail/detail'
		})
	}
}
export default new HousePage()